﻿using System.Collections.ObjectModel;
using System.Linq;
using Moven.ViewModels;

namespace Moven.Views
{
	public class BaseArticlesPage: BasePage
	{
		public bool IsNavigatingBack => Navigation.NavigationStack.Last() is ArticleDetailsView;

		protected ArticlesViewModel ViewModel => BindingContext as ArticlesViewModel;

		protected ObservableCollection<ArticleWithBookmark> Articles => ViewModel.Articles;

		public BaseArticlesPage()
		{
			this.SetBackButtonTitle();
		}

		protected override void OnAppearing()
		{
			base.OnAppearing();
			UpdateUI();
		}

		protected virtual void UpdateUI()
		{
			ViewModel.UpdateTitle();
		}
	}
}
